{include file="pub:header"/}
<script type="text/javascript">
$(function(){
	$('.J_tablelist').listTable();
});
function setSort() {
	$('#myform').attr('action', "{:url('sort')}");
	ajaxpost('myform');
}
function setStatus(id, status) {
	if(!id || id.length == 0)return alert("请选择一条记录");

	$('#myform').attr('action', "{:url('state')}");
	$('#state').val(status);
	ajaxpost('myform');
}
function editConfig(id){
  art.dialog.open('{:url('config/edit')}?id='+id,{title:'配置参数编辑',id:'cats',width:750,height:550,lock: true,fixed:true,close:function(){location.reload(true);}});
}
</script>
</head>
<body>


	<div class="subnav">
		<div class="content_menu ib_a blue line_x">
            <a href="javascript:;"><span class="pagetitle">【配置参数管理】</span></a>
            <span>|</span>
			<a class="add fb J_showdialog" href="javascript:;" onclick="editConfig(0);"><em>添加配置</em></a>
		</div>
	</div>

	<div class="pad_lr_10">

		<form action="{:url('index')}" method="get">

			<table width="100%" cellspacing="0" class="search_form">
			<input type="hidden" name="state" value="{$state}">
				<tbody>
					<tr>
						<td>
							<div class="explain_col">
								分组
								<select name='group' class='select'>
									<option value='0'>所有</option>
									{volist name=":config(CONFIG_GROUP_LIST)" id="vo"}
									<option value='{$key}' {if condition="$group eq $key"}selected{/if}>
									   {$vo}
									</option>
									{/volist}
								</select>
								类型
								<select name='type' class='select'>
									<option value=''>所有</option>
									{volist name=":config(CONFIG_TYPE_LIST)" id="vo"}
									<option value='{$key}' {if condition="($type neq '') AND ($type eq $key)"}selected{/if}>
									    {$vo}
									</option>
									{/volist}
								</select>
								名称或标题
								<input name="keyword" type="text" class="input-text" size="30" value="{$keyword}">
								<input type="submit" class="btn" value="搜索" />
							</div>
						</td>
					</tr>
				</tbody>
			</table>

		</form>


      <div class="col_tab" style="margin-top:5px;">
		<ul class="J_tabs tab_grid cu_li">
		   {volist name="reviewary" id="vo"}
		   <li<?php echo $key==$state?' class="current"':'' ?>><a href="{:url('index')}?state={$key}">{$vo}</a></li>
		   {/volist}
		</ul>

		<div class="J_tablelist table_list">

			<table width="100%" cellspacing="0">

				<thead>
					<tr>
					    <th width="40"><input type="checkbox" name="checkall" class="J_checkall"></th>
						<th>编号</th>
						<th align="left">参数名称</th>
						<th align="left">标题</th>
						<th align="left">分组</th>
						<th align="left">类型</th>
						<th>状态</th>
						<th>排序</th>
						<th>操作</th>
					</tr>
				</thead>

				<form action="" id="myform">
				<input type="hidden" name="state" value="1" id="state">
					<tbody>
						{volist name="list->toArray()['data']" id="vo"}
						<tr>
						    <td align="center"><input type="checkbox" name='id[]' class="J_checkitem" value="{$vo['id']}"></td>
							<td align="center">{$vo['id']}</td>
							<td>{$vo['name']}</td>
							<td>{$vo['title']}</td>
							<td>{$vo['group']|get_config_group}</td>
							<td>{$vo['type']|get_config_type}</td>
							<td align="center"><?php echo 1==$vo['state']?"<font color='green'>启用</font>":"<font color='red'>禁用</font>";?></td>
							<td align="center">
								<input type="text" name="sort[{$vo['id']}]" style="text-align: center;" class="input-text" size="8" value="{$vo['sort']}">
							</td>
							<td align="center">
								【<a href="javascript:;" onclick="editConfig({$vo['id']})" title="点击修改配置">修改</a>】
								<?php if(1==$vo['state']){ ?>
							            【<a href="javascript:;" onclick="ajaxurl('{:url('state',array('id'=>$vo['id'],'state'=>0))}');" title="点击禁用">禁用</a>】
								<?php }else{ ?>
								【<a href="javascript:;" onclick="ajaxurl('{:url('state',array('id'=>$vo['id'],'state'=>1))}');" title="点击启用"><font color="red">启用</font></a>】
								<?php } ?>
								【<a href="javascript:;" onclick="ajaxget('{:url('delete',array('id'=>$vo['id']))}','删除后不可恢复，确认删除？')" title="点击删除配置">删除</a>】
							</td>
						</tr>
						{/volist}

						{empty name="list"}
						<tr>
							<td colspan="9" align="center">暂无数据 !</td>
						</tr>
						{/empty}
					</tbody>
				</form>

			</table>

		</div>

		</div>


		<div class="btn_wrap_fixed">
		    <label class="select_all mr10"><input type="checkbox" name="checkall" class="J_checkall">全选/取消</label>
			<input type="button" class="btn" onclick="setSort();" value="排序" />
            <input type="button" value="批量启用" class="btn" onclick="setStatus($.checkBoxValue('id[]'), 1)"/>
            <input type="button" value="批量禁用" class="btn" onclick="setStatus($.checkBoxValue('id[]'), 0)"/>
			<div id="pages">{$list|raw}</div>
		</div>

    </div>

{include file="pub:footer" /}
